#include<math.h>
#include<iostream>
#include<stack>
#include<set>
using namespace std;
const int MaxN = 150;
int mat[MaxN][MaxN];
//计算以ij为右下角的新行与新列之和
int f1(int n, int nowi, int nowj,int sti,int stj, int mat[MaxN][MaxN])
{
	int sum = 0;
	for (int i = sti; i <= nowi; i++)
	{
		sum += mat[i][nowj];
	}
	for (int j = stj; j < nowj; j++)
	{
		sum += mat[nowi][j];
	}
	return sum;
}
//计算以ij为左上角的最大矩阵
int max_i_j(int n, int i, int j, int mat[MaxN][MaxN])
{
	int* dp = new int[n];
	int sti = i,stj = j;
	int t = 0;
	for (t = 0; t < n; t++)
	{
		dp[t] = INT_MIN;
	}
	//第一个左上角同时也是第一个右下角
	dp[0] = mat[i][j];
	//由于确定了左上角，只要确定右下角即可。
	t = 1;
	while (++i < n && ++j < n && t < n)
	{
		dp[t] = dp[t - 1] + f1(n, i, j, sti, stj, mat);
		t++;
	}
	int maxre = INT_MIN;
	for (t = 0; t < n; t++)
	{
		//st已经用不到的
		if (maxre < dp[t])
		{
			maxre = dp[t];
		}
	}
	return maxre;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			mat[i][j]=INT_MIN;
		}
	}
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> mat[i][j];
		}
	}
	//
	int allmax = INT_MIN;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			//计算以ij为左上角的最大矩阵
			int tmp=max_i_j(n, i, j, mat);
			//cout << tmp << "\t";
			if (tmp > allmax)
			{
				allmax = tmp;
			}
		}
		//cout <<"\n";
	}
	cout << allmax;
}
